package com.aegean.MonitorExamSYS.center.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.util.ServletContextAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.center.business.CenterBusiness;
import com.aegean.MonitorExamSYS.center.component.SelectConductionInfo;
import com.opensymphony.xwork2.ActionSupport;

@Controller("ConfirmConductionPre")
@Scope("prototype")
public class ConfirmConductionPre extends ActionSupport implements
		ServletRequestAware {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5684679535347990859L;
	@Resource
	private CenterBusiness business;
	private HttpServletRequest request;
	private Map<Integer, List<Integer>> con_PositionsMap;
	private int[] conduction_Ids;
	private int state;
	private int conduction_Id;
	private boolean success;
	private String msg;
	private boolean newN;// 判断是否去安排新的考试
	private HttpSession session;

	public boolean isNewN() {
		return newN;
	}

	public void setNewN(boolean newN) {
		this.newN = newN;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getConduction_Id() {
		return conduction_Id;
	}

	public void setConduction_Id(int conduction_Id) {
		this.conduction_Id = conduction_Id;
	}

	public int[] getConduction_Ids() {
		return conduction_Ids;
	}

	public void setConduction_Ids(int[] conduction_Ids) {
		this.conduction_Ids = conduction_Ids;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		if (newN) {
			session.removeAttribute("confirmConductionsMap");
			con_PositionsMap = new HashMap<Integer, List<Integer>>();
			for (Integer one : conduction_Ids) {
				con_PositionsMap.put(one, null);
			}
			session.setAttribute("confirmConductionsMap", con_PositionsMap);
			success = true;
			msg = "成功确定了考点的信息，请在相应的考点之中选择对应符合的考场！";
		}
		return SUCCESS;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
		session = request.getSession();
	}

}
